import org.apache.ibatis.session.SqlSession;
import org.junit.Test;
import uity.MBgetSession;

import java.io.IOException;
import java.util.List;

public class student {
    @Test
    public void select() throws IOException {
        SqlSession sqlSession = MBgetSession.getsqlSession();
        List<MBstudent> mbSelectStudentAll = sqlSession.selectList("MBSelectStudentAll");
        for (MBstudent mBstudent : mbSelectStudentAll) {
            System.out.println(mBstudent);
        }
    }

    @Test
    public void update() throws IOException {
        SqlSession sqlSession = MBgetSession.getsqlSession();
        MBstudent MBStudentUpd = new MBstudent(6, "test7");
        int num = sqlSession.update("MBUpdStudent",MBStudentUpd);
        sqlSession.commit();
        if (num > 0) {
            System.out.println("成功修改" + num + "条信息");
        }else{
            System.out.println("未作更改");
        }
    }

    @Test
    public void dele() throws IOException {
        SqlSession sqlSession = MBgetSession.getsqlSession();
        int num = sqlSession.delete("MBDelStudent", 6);
        sqlSession.commit();
        if (num > 0) {
            System.out.println("成功删除" + num + "条信息");
        }else{
            System.out.println("未作更改");
        }

    }

    @Test
    public void add() throws IOException {
        SqlSession sqlSession = MBgetSession.getsqlSession();
        MBstudent MBStudentAdd = new MBstudent(6, "test6");
        int num = sqlSession.insert("MBAddStudent", MBStudentAdd);
        sqlSession.commit();
        if (num > 0) {
            System.out.println("成功添加" + num + "条信息");
        }else{
            System.out.println("未作更改");
        }
    }

}
